#include "process.h"

void Process::set_arrival_time(int AT) { arrival_time = AT; }

void Process::set_total_time(int TT) { total_time = TT; }

void Process::set_finishing_time(int FT) { finishing_time = FT; }

void Process::set_cpu_burst(int CB) { cpu_burst = CB; }

void Process::add_cpu_waiting(int CPU) { cpu_waiting += CPU; }

void Process::set_time_prev_state(int TPS) { time_in_previous_state = TPS; }

void Process::set_priority(int P) {
  priority = P;
  dynamic_priority = P - 1;
}

int Process::get_time_prev_state() { return time_in_previous_state; }

void Process::set_io_burst(int IO) { io_burst = IO; }

void Process::set_pid(int p) { pid = p; }

// Getters
int Process::get_finishing_time() { return finishing_time; }

int Process::get_cpu_waiting() { return cpu_waiting; }

int Process::get_arrival_time() { return arrival_time; }

int Process::get_total_time() { return total_time; }

int Process::get_cpu_burst() { return cpu_burst; }

int Process::get_io_burst() { return io_burst; }

void Process::add_time_running(int r) { time_running += r; }

void Process::add_time_blocked(int b) { time_blocked += b; }

int Process::get_time_blocked() { return time_blocked; }

int Process::get_pid() { return pid; }

int Process::get_time_running() { return time_running; }

int Process::get_priority() { return priority; }

int Process::get_remaining_time() { return total_time - time_running; }

void Process::set_incrementally(int val) {
  if (arrival_time == -1) {
    arrival_time = val;
    last_event_time = val;
  } else if (total_time == -1) {
    total_time = val;
  } else if (cpu_burst == -1) {
    cpu_burst = val;
  } else if (io_burst == -1) {
    io_burst = val;
  }
}
